package com.goldmantis.alitrip.common;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.shiro.crypto.hash.SimpleHash;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @Author:Shmily
 * @Description:
 * @Date:Create in 15:22 2018/2/11
 */
public class SecurityHelper {

    public static String encrpt(String toEncryptString) throws Exception {
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        byte[] digest = md.digest(toEncryptString.getBytes("UTF-8"));
        return new String(Base64.encodeBase64(digest));
    }

}
